package com.jwell.panprovider.presenter

import com.jwell.driverapp.tools.BaseSubscriber
import com.jwell.driverapp.ui.base.BasePresenter
import com.jwell.panprovider.contract.PreRegisterContract
import com.jwell.panprovider.model.PreRegisterModel
import org.json.JSONObject
import org.reactivestreams.Subscription

/**
 * Created by 76577 on 2018/4/9.
 * 预登记
 */
class PreRegisterPresenter : PreRegisterContract.Presenter, BasePresenter<PreRegisterContract.View>() {
    private val model: PreRegisterModel by lazy {
        PreRegisterModel()
    }

    override fun createWaybill(data: PreRegisterModel.RequestData) {
        model.createWaybill(data, object : BaseSubscriber() {
            override fun setSubscription(s: Subscription) {
                mSubscription = s
            }

            override fun succeed(data: JSONObject) {
                getView()?.hideProgress()
                getView()?.createSucceed()
            }

            override fun onFailed(msg: String) {
                getView()?.hideProgress()
                getView()?.createFailed(msg)
            }
        })
    }
}